///////////////////////////////////////////////////////////
///////////////// Have an itch? Scratch it! ///////////////
///////////////////////// SCRATCH /////////////////////////
/////////////////////  A MUD  Server   ////////////////////
///////////////////// By: Jared Devall ////////////////////
/////////////////////      Thanks:     ////////////////////
/////////////////////  DIKU/Merc/ROM   ////////////////////
///////////////////// Aetas/Deus Gang  ////////////////////
/////////////////////       Beej       ////////////////////
///////////////////////////////////////////////////////////

#ifndef __TIMER_H
#define __TIMER_H

#include <ctime>

// Thanks for the help Eiz

typedef unsigned long long int ustime_t;

class Timer {
	public:
	bool _enabled; 	
 
    private:
    int _interval;
    int _times; 	
    ustime_t _when;
 
    public:
    Timer( int interval, int times );
    ustime_t GetTime( void );
 
    virtual ~Timer() { }
 
    // Resets the tick count to 0.
    void Reset( void );
 
    // Fires the timer.  Returns true if we wish to fire
    // again sometime in the future (the when() time will
    // change), false if otherwise.
    bool Fire( void );
 
    // Returns the time to execute.
    time_t When( void ) const;

    // Execute the function associated with the timer, return
    // the status of the timer.
    virtual bool Execute( void ) = 0;
 };

struct timer_less {
	bool operator() ( const Timer *lhs, const Timer *rhs ) const {		
		return lhs->When() > rhs->When();
 	}
};
 
inline time_t Timer::When() const {
 	return _when;
} 
#endif // __TIMER_H
